#include <stdio.h>

int main() {
    int i, j, t, k, n;
    int a[10];/* 定义1个数组a，它有10个整型元素*/
    printf("Enter the number of elements: ");
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        printf("a[%d] = ", i);
        scanf("%d", &a[i]);
    }
    for (i = 0; i < n - 1; i++) {   /* a[i]与其后所有元素比较，若a[j]小于a[i]，则交换*/
        for (j = i + 1; j < n; j++)
            if (a[i] > a[j]) {
                t = a[i];
                a[i] = a[j];
                a[j] = t;
            }
    }
    printf("After sorted: ");
    for (i = 0; i < n; i++)      /* 输出n个数组元素的值 */
        printf("%d ", a[i]);
    return 0;
}
